package com.showcai.controller.getUserInfo;

import com.showcai.controller.base.WeChatBaseController;
import com.showcai.module.sync.SyncOrder;
import com.showcai.module.sync.UserToken;
import com.showcai.service.GetUserInfoService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;


@RequestMapping("/unicom")
@Controller
public class GetUserInfoController extends WeChatBaseController {

    @Autowired
    GetUserInfoService getUserInfoService;


    /**
     * 联通选号通过userToken获取用户信息
     * @return
     */
    @RequestMapping(value="/getInfo",method = RequestMethod.POST )
    @ResponseBody
    public String getUserInfo() {
        UserToken userToken=(UserToken)super.json2Obj(UserToken.class);
        String str = getUserInfoService.getUserInfo(userToken.getUserTokenCode());
        return str;
    }

    /**
     * 保存用户订单信息，更新选号状态
     * @return
     */
    @RequestMapping(value="/syncOrder",method = RequestMethod.POST )
    @ResponseBody
    public String saveOrder() {

        SyncOrder syncOrder= (SyncOrder) super.json2Obj(SyncOrder.class);
        String shopCenterId=syncOrder.getShopCenterId();
        String saleOrderNo=syncOrder.getSaleOrderNo();
        String mobile=syncOrder.getMobile();
        String uniqueNo=syncOrder.getUniqueNo();

        String str = getUserInfoService.saveOrder(shopCenterId,saleOrderNo,mobile,uniqueNo);
        return str;
    }




}
